package com.lx.spring;

import com.lx.spring.mapper.UserMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
//组件扫描, 扫描指定的包和子包
@ComponentScan("com.lx.spring")
//@ComponentScan 除了会扫描到组件, 也会扫描到配置类，
//扫描到的配置类也会被执行加载
public class AutoWriteAnnoConfig {


    @Bean("myUserMapper")
    public UserMapper userMapper(){
        UserMapper userMapper = new UserMapper();
        userMapper.setName("李四");
        return userMapper;
    }

}
